package cn.fl.flow.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.flow.service.IFlowFrmAthRecService;
import cn.fl.flow.transform.FlowFrmAthRecVOTransform;
import cn.fl.flow.vo.FlowFrmAthRecVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import fl.flow.facade.flow.api.IFlowApiService;
import fl.flow.facade.flow.api.IFlowQueryApiService;
import fl.flow.facade.flow.condition.FlowFrmAthRecQC;
import fl.flow.facade.flow.dto.FlowFrmAthRecDTO;

/**
 * @Description: 流程中节点附加页面会有权限控制, 节点上审核人员会配置这个功能权限。 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class FlowFrmAthRecServiceImpl implements IFlowFrmAthRecService {
	
	private static final Logger logger = LoggerFactory.getLogger(IFlowFrmAthRecService.class);

	@Autowired
	private IFlowApiService flowApiService;
	@Autowired
	private IFlowQueryApiService flowQueryApiService;
	
	@Override
	public boolean addAndModify(List<FlowFrmAthRecVO> list, Long dataId, String taskId) throws BaseException {
		return this.flowApiService.addFlowFrmAthRec(FlowFrmAthRecVOTransform.toDTOList(list), true, dataId, taskId);
	}

	@Override
	public List<FlowFrmAthRecDTO> searchFlowFrmAthRec(FlowFrmAthRecQC qc) throws BaseException {
		if(null == qc) return new ArrayList<>();
		return this.flowQueryApiService.searchFlowFrmAthRec(qc);
	}

	@Override
	public Map<String, String> searchFlowFrmAthRecToMap(FlowFrmAthRecQC qc) throws BaseException {
		Map<String, String> map = new HashMap<>();
		if(null == qc) return map;
		List<FlowFrmAthRecDTO> list = this.flowQueryApiService.searchFlowFrmAthRec(qc);
		if(CollectionUtils.isNotEmpty(list)){
			for (FlowFrmAthRecDTO flowFrmAthRecDTO : list) {
				String athCd = flowFrmAthRecDTO.getAthCd();
				String athCdNm = flowFrmAthRecDTO.getAthCdNm();
				map.put(athCd, athCdNm);
			}
		}
		return map;
	}
	
	
	
	
}
